import threading
import random
import time

'''
线程锁
'''

lock = threading.Lock()

list1 = [0] * 1150


def task1():
    lock.acquire()
    for i in range(len(list1)):
        list1[i] = 1
        #print('---task1----->',list1[i])
        time.sleep(0.5)
    lock.release()
    

def task2():
    lock.acquire()
    for i in range(len(list1)):
        print('-------->',list1[i])
        time.sleep(0.5)
    lock.release()
    
    
    
if __name__ == '__main__':
    t1 = threading.Thread(target=task1)
    t2 = threading.Thread(target=task2)
    
    t2.start()
    t1.start()
    
    
    t2.join()
    t1.join()
    
    print(list1)